/*****************************************************************************************************************************
 * \file:    
 * \module:  
 * \brief:   
 * \project: 
 * \author:  
 *============================================================================================================================
 *                                                   Revision control History
 *============================================================================================================================
 * V1.0.0: 2021-06-30: Initial Version
 *
 *
 *
 ****************************************************************************************************************************/
#ifndef SCH_H
#define SCH_H

/*****************************************************************************************************************************
 * Other header files
 ****************************************************************************************************************************/
#include "stdint.h"

/*****************************************************************************************************************************
 * Macro decalaration
 ****************************************************************************************************************************/
#define SCH_MAX_TASKS                   (3U)

#define TASK1_DELAY                     (1U)
#define TASK1_PERIOD                    (5U)

#define TASK2_DELAY                     (2U)
#define TASK2_PERIOD                    (10U)

#define TASK3_DELAY                     (4U)
#define TASK3_PERIOD                    (50U)


/*****************************************************************************************************************************
 * Enum decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * union decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * typedef compound type decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * Struct decalaration
 ****************************************************************************************************************************/
typedef struct {
	void (*pTask)(void);
    uint16_t DelayTime;
    uint16_t Period;
    uint16_t Runtimes;
} Task_ObjType;
/*****************************************************************************************************************************
 * Global variable decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * Global function declaration prototype 
 ****************************************************************************************************************************/
/*!
 * \brief Scheduler init API
 * \param[in] void
 * \return void
 */
extern void SCH_Init(void);
/*!
 * \brief Scheduler start API
 * \param[in] void
 * \return void
 */
extern void SCH_Start(void);
/*!
 * \brief Scheduler add task to queue API
 * \param[in] TaskPtr target task
 * \param[in] TaskDelay task delay schedule parameter
 * \param[in] TaskPeriod task schedule cycle
 * \return void
 */
extern uint32_t  SCH_Add_Task(void(*TaskPtr)(void), uint16_t TaskDelay,  uint16_t TaskPeriod);
/*!
 * \brief Scheduler update API, called by timer interrupt
 * \param[in] void
 * \return void
 */
extern void SCH_Update(void);
/*!
 * \brief delete task from schedule queue
 * \param[in] TaskID task identifier
 * \return void
 */
extern void SCH_Delete_Task(uint16_t TaskID);
/*!
 * \brief Scheduler dispatch API , to find which task will be called
 * \param[in] void
 * \return void
 */
extern void SCH_Dispatch_Tasks(void);
/*!
 * \brief Get task runtimes attribute
 * \param[in] TaskID task identifier
 * \return void
 */
extern uint32_t SCH_GetTaskRuntimes(uint16_t TaskID);


extern void OS_TimeDelay(const uint32_t delay);
/*****************************************************************************************************************************
 * END OF FILE: Sch.h
 ****************************************************************************************************************************/
#endif
